
public class Curve extends Geometry {
	
	Point[] points;
	
	public Curve(Point[] p){
		super.type = "Curve";
		points = p;
	}

	
	public int Dimension() {
		return 2;
	}

	public int IsEmpty() {
		return 0;
	}
	
	public Point StartPoint(){
		return points[0];
	}
	
	public Point EndPoint(){
		return points[points.length-1];
	}
	
	public int IsClosed(){
		if(StartPoint() == EndPoint()){
			return 1;
		}
		else{
			return 0;
		}
	}
	
	public int IsSimple(){
		//Compares all points to see if equal
		int check = 0;
		for(int checked = 0;checked<=points.length-2;checked++){
			for(int checking = checked+1;checking<=points.length-1;){
				if (points[checked] == points[checking]){
					check = 1;
					break;
				}
			}
			if (check == 1) break;
		}
		return check;
	}
	
	public double Length(){
		double length = 0;
		int compare1 = 0;
		int compare2 = 1;
		while(compare2 <= points.length-1){
			//Get length of segment
			//x
			double x = points[compare1].X() - points[compare2].X();
			if(x<0) x=x*-1;
			x = x*x;
			//y
			double y = points[compare1].Y() - points[compare2].Y();
			if(y<0) y=y*-1;
			y = y*y;
			//Add results to running total of length
			length = length + Math.sqrt(x + y);
			compare1++;
			compare2++;
		}
		return length;
	}

}
